<template>
    <div>

      <form action="">
        <input type="text" v-model="name">用户名
        <input type="text" v-model="tel">手机号
        <button @click="on_add">提交订单</button>
      </form>
    </div>
</template>

<script>
    import axios from "axios";

    export default {
        name: "ding",
        data(){
          return{
            name:'',
            tel:'',
            gid:this.$route.query.gid,

          }
        },

        methods: {

          on_add() {
            var uid = localStorage.getItem('uid');
            let form_data = new FormData();
            form_data.append('name', this.name);
            form_data.append('tel', this.tel);
            form_data.append('gid', this.gid);
            form_data.append('uid', uid);

            axios({
              method: 'POST',
              url: 'http://127.0.0.1:8000/ding/',
              data: form_data

            }).then(res => {
              console.log(res);
              if(res.data.code==200){
                this.$router.push('/show')
              }else {
                alert(res.data.message)
              }

            })

          }
        }
    }
</script>

<style scoped>

</style>
